package krao.data;

import java.util.HashSet;

/**
 * Class for holding answer after evaluation of UnionConjQuery over ABox.
 * 
 * @author Pepe
 * @see UnionConjQuery
 * @see ABox
 */
public class QueryAnswer {
	public void setAnswer(HashSet<String> answer) {
		this.answer = answer;
	}

	private ConjQuery answerTo;
	private String sqlQuery;
	private String headVariable;

	public String getHeadVariable() {
		return headVariable;
	}

	public void setHeadVariable(String headVariable) {
		this.headVariable = headVariable;
	}

	public String getSqlQuery() {
		return sqlQuery;
	}

	public void setSqlQuery(String sqlQuery) {
		this.sqlQuery = sqlQuery;
	}

	public ConjQuery getAnswerTo() {
		return answerTo;
	}

	public void setAnswerTo(ConjQuery answerTo) {
		this.answerTo = answerTo;
	}

	private HashSet<String> answer = new HashSet<String>();

	public QueryAnswer(ConjQuery cq) {
		answerTo = cq;
	}

	public HashSet<String> getAnswer() {
		return answer;
	}

	public void addToAnswer(String thisAnswer) {
		answer.add(thisAnswer);
	}

	public boolean isEmpty() {
		return answer == null || answer.isEmpty();
	}

	@Override
	public String toString() {
		return headVariable + ":" + answer.toString();
	}
}
